package com.xinxing.city.recovery.utils;

public class VersionUtil {

    public int compareVersion(String version1, String version2) {
        String[] nums1 = version1.split("\\.");
        String[] nums2 = version2.split("\\.");
        int n1 = nums1.length;
        int n2 = nums2.length;
        for (int i = 0; i < Math.max(n1, n2); i++) {
            int num1 = i < n1 ? Integer.parseInt(nums1[i]) : 0;
            int num2 = i < n2 ? Integer.parseInt(nums2[i]) : 0;
            if (num1 != num2) {
                return num1 < num2 ? -1 : 1;
            }
        }
        return 0;
    }

}
